<?php
namespace app\admin\logic;

class ClassLearnRecordLogic extends BaseLogic {

    /**
     * 获取学习记录查询条件
     * @param $clid
     * @param $username
     * @param $start_time
     * @param $end_time
     * @return array
     */
    public function get_search_clr_maps($clid,$username,$start_time,$end_time){
        $maps = [];
        $maps[] = ['clid','=',$clid];
        $maps[] = ['end_time','>','0000-00-00 00:00:00'];

        if(!empty($username)){
            $u_maps = [];
            $u_maps[] = ['username','like','%' . $username . '%'];
            $openids = model('user')->get_column($u_maps,'openid');
            $maps[] = ['openid','in',$openids];
        }

        if(!empty($start_time) && !empty($end_time)){
            $maps[] = ['start_time','between',[$start_time,$end_time]];
        }
        return $maps;
    }
}